package com.atguigu.spring5.service;

import com.atguigu.spring5.dao.BookDao;
import com.atguigu.spring5.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {


    @Autowired
    private BookDao bookDao;


    //添加的方法
    public void addBook(Book book) {
        bookDao.add(book);
    }

    //修改的方法
    public void updateBook(Book book) {
        bookDao.updateBook(book);
    }

    //删除的方法
    public void deleteBook(Long id) {
        bookDao.delete(id);
    }


    //查询表记录数
    public int findCount() {
        int selectCount = bookDao.selectCount();
        return selectCount;
    }

    //根据id查询
    public Book findBookInfo(Long id) {
        Book book = bookDao.findBookInfo(id);
        return book;
    }

    //查询返回集合
    public List<Book> findAll() {
        return bookDao.findAll();
    }


    //批量添加
    public void batchInsert(List<Object[]> list) {
        bookDao.batchInsert(list);
    }

    //批量修改
    public void batchUpdate(List<Object[]> list) {
        bookDao.batchUpdate(list);
    }

    //批量删除
    public void batchDelete(List<Object[]> list) {
        bookDao.batchDelete(list);
    }

}
